<#assign StringUtils = beansWrapperFn.getStaticModels()["org.apache.commons.lang3.StringUtils"]>
SELECT
t.*
FROM
c1_user t
WHERE 1 = 1
<#if StringUtils.isNotBlank(userName)>
AND INSTR(t.`NAME`, :userName) > 0
</#if>
<#if StringUtils.isNotBlank(userCode)>
AND INSTR(t.`CODE`, :userCode) > 0
</#if>
<#if StringUtils.isNotBlank(dataStates)>
AND INSTR(:dataStates, T.`DATA_STATE_ID`) > 0
</#if>
<#if StringUtils.isBlank(orgId)>
    <#if !isAdmin>
    AND 1 = 2
    </#if>
<#else>
AND T.ORG_ID = :orgId
</#if>
<#if StringUtils.isNotBlank(flagCode)>
AND T.FLAG_CODE = :flagCode
</#if>
ORDER BY T.CREATED_DATE DESC, t.`CODE`
LIMIT <#if (begin_row_num??)>:begin_row_num<#else>0</#if>, <#if (size??)>:size<#else>20</#if>
